package engine.newUi
{
	import engine.GameData;
	import engine.control.MenuList;
	import engine.control.NxTablePageTurner;
	import engine.control.loading.NxLoading;
	import engine.data.ModelLocator;
	import engine.data.RoleVo;
	import engine.flag.GameDefine;
	import engine.logic.ActSee;
	import engine.logic.ChatFilterLogic;
	import engine.logic.SceneTransfer;
	import engine.logic.login.NxCallLater;
	import engine.net.datatype.WString;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.player.RoleModel;
	import engine.tip.TipsMainLogic;
	import engine.ui.AlertUI;
	import engine.ui.UIManage;
	import engine.ui.lite.BaseUI;
	import engine.util.FilterUtil;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.text.TextFormatAlign;
	import flash.utils.Timer;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.group.NxViewGroup;
	import newx.com.control.tab.NxTab;
	import newx.com.control.tab.NxTabEvent;
	import newx.com.control.table.NxTabelPos;
	import newx.com.control.table.NxTable;
	import newx.com.control.table.NxTableEvent;
	import newx.com.control.table.TableCellFactory;
	import newx.com.control.text.NxLabel;
	import newx.com.control.text.NxText;
	import newx.com.control.window.NxWindowEvent;

	/**
	 *家族主界面 
	 * @editor gf 
	 */	
	public class FamilyInfoUI extends BaseUI
	{
		private static var _self				:FamilyInfoUI;
		public var _fenge:MovieClip;
		public var _fengetiao:MovieClip;
		public var lab_notice:Sprite;
		/**
		 *UIString_1000106 批准
			UIString_1000107 拒绝 
		 */		
		private const AGREE_STR:String=StaticIni.getSwfLangStr("UIString_1000106"),
			DECLINE_STR:String=StaticIni.getSwfLangStr("UIString_1000107");
		private const  SPLITER:String="$6$"
			
		//------------------------------------------------------------------------------------
		/**窗口描述背景*/
		public 		var		_descriptionBg		:MovieClip;
		/**窗口描述*/
		public		var		_description		:NxText;
		/** 家族信息背景 */
		public		var		_familyInfoBg		:MovieClip;
		/** 家族名称标签 */
		public		var		_familyNameLabel	:NxLabel;
		/** 家族长标签 */
		public		var		_familyShaikhLabel	:NxLabel;
		/** 家族等级标签 */
		public		var		_familyLevelLabel	:NxLabel;
		/** 家族经验标签 */
		public		var		_familyExpLabel		:NxLabel;
		/** 家族人数标签 */
		public 		var 	_familyMemberLabel	:NxLabel;
		/** 家族金库标签 */
//		public 		var 	goldLabel			:NxLabel;
		/** 家族日经验标签 */
//		public		var		_familyDataExpLabel:NxLabel;
		/** 家族日福利标签 */
//		public		var		_familyDataWelfareLabel:NxLabel;
		/** 家族名称 */
		public		var		_familyName		:NxLabel;
		/** 家族长 */
		public		var		_familyShaikh	:NxLabel;
		/** 家族等级 */
		public		var		_familyLevel	:NxLabel;
		/** 家族经验 */
		public		var		_familyExp		:NxLabel;
		/** 家族人数信息 */
		public 		var 	_familyMember	:NxLabel;
		
		/***一周的总贡献***/
		public 		var 	lab_weakCount	:NxLabel;
		/** 家族金库值 */
//		public 		var 	goldNum			:NxLabel;
		
		/** 家族管理按钮 */
		public 		var 	manageBtn		:NxButton;
		/** 家族领地战*/
//		public 		var 	battleBtn		:NxButton;
		
		/** 家族日经验 */
//		public		var		_familyDataExp	:NxLabel;
		/** 家族日福利 */
//		public		var		_familyDataWelfare:NxLabel;
		
		public 		var		_tabBg			:MovieClip;
		
		public		var		_tab			:NxTable;
		/**向上翻页按钮*/
		public		var		_pageUpBtn		:NxButton;
		/**向下翻页按钮*/
		public		var		_pageNextBtn	:NxButton;
		/**可翻页数文字背景*/
		public		var		_pageBg			:MovieClip;
		/**可翻页数显示*/
		public		var		_pageNum		:NxLabel;
		/**显示全部成员**/
		public 		var 	lab_showAllRole	:NxLabel;
		
		public 		var 	info_tab		:NxTab;
		/**帮派总坛**/
		public 		var 	baseBtn			:NxButton;
		/** 邀请成员 */
		public		var		_familyInviteBtn:NxButton;
		/** 退出家族 */
		public		var		_familyExitBtn	:NxButton;
		/** 解散家族 */
		public		var		_FamilyDismissBtn:NxButton;
		/** 处理申请 */
//		public		var		_familyDoApplyBtn:NxButton;
		
		public 		var		btn_switchHead:NxButton;
		/** 家族公告 */
		public		var		_familyPlacardBtn:NxButton;
		/** 家族排行 */
		public		var		_familyRankBtn	:NxButton;
		/** 家族挑战 */
//		public		var		_gainFamilyChaeBtn:NxButton;
		/** 家族捐献 */
		public		var		_familyRank2Btn	:NxButton;
		/** 家族宝库 */
//		public		var		_familyTreasureBtn	:NxButton;
		
		/**一个美化框，不用管*/
//		public		var 	_familyInfoBg2:DisplayObject;
		
		//帮派福利
		public var _fuliMc:Sprite;
		public var _fuliLevel:NxLabel;
		public var _fuliloading:NxLoading;
		public var _fulileft:NxLabel;
		public var _fuliGroup:NxViewGroup;
		public var _fuliBg:Sprite;
		public var _fuliLine:Sprite;
		public var _fuliMc2:Sprite;
		public var _fuliloadLab:NxLabel;
		
		//------------------------------------------------------------------------------
		
		/**NxTable翻页管理*/
		private 	var 	_pageTurner:NxTablePageTurner;
		
		private	var		model			:ModelLocator;
//		//选中的家族成员
//		private 	var		_seltFamilyRole	:String		=	"";
		private 	var		_seltFamilyRole	:Array		=	new Array();
		//在家族中的职位
		private 	var		_familyPlace	:int		=	-1;//1为族长，2为长老，3为成员
		
		private 	var 	menuList		:Array		=[];
		/***帮主离线时间**/
		private 	var 	familyHeadTime:int = 0;
		/**弹按纽**/
		public 		var 	_tanheBtn:NxButton ;
		/**弹劾显示的TIPS**/
		public 		var 	_tanheTipsStr:String = "";
		
		private 	var 	_timeCount:int = 0;
		private    var 	_timer:Timer;
		
		/**副帮主数组***/
		private var _switchDataArr:Array = [];
		
		private var _roleVo:RoleVo ;
		
		public  var checkBox:MovieClip;
		
		private var _widthArr:Array = [];
		
		private var showdataList:Array = [];
		
		private var _tableCellFactory:TableCellFactory;
		//帮派当前经验
		private var _familyCurExp:int = 0;
		public function FamilyInfoUI()
		{
			super();
			
		}
		
		public static function getInstance():FamilyInfoUI
		{
			if(_self==null)
			{
				_self = new FamilyInfoUI();
			}
			return _self;
		}
		
		override public function Init():void
		{
			info_tab.dataProvider = [
				{label:StaticIni.getSwfLangStr("GuildUIStr_15"),data:"GuildUIStr_15"},
				{label:StaticIni.getSwfLangStr("GuildUIStr_16"),data:"GuildUIStr_16"},
				{label:StaticIni.getSwfLangStr("UIString_1000564"),data:"UIString_1000564"},
				{label:StaticIni.getSwfLangStr("UIString_1000736"),data:"UIString_1000736"}];
//			manageBtn.visible = false;
//			_familyRank2Btn.visible = false;\public var _fuliMc:Sprite;
			_fuliMc.visible			= false;
			_fuliLevel.visible		= false;
			_fuliloading.visible	= false;
			_fulileft.visible		= false;
			_fuliGroup.visible		= false;
			_fuliBg.visible			= false;
			_fuliLine.visible		= false;
			_fuliMc2.visible		= false;
			_fuliloadLab.visible	= false;
			checkBox.buttonMode		= false;
			checkBox.gotoAndStop(2);
			_pageTurner=new NxTablePageTurner(_pageUpBtn,_pageNextBtn,_tab,_pageNum,beforePageTurn);
			model			=	ModelLocator.getInstance();
			_roleVo		= model.scene.Role;
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SHOW_GUILD_INFO),onShowFamily);
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_OPEN_GUILD_UI),onShowFamilyUI);
			
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_GUILD_MSG),onShowGold);
			
			//反叛选择事件，弹出选择框
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_OPEN_GUILD_BETRAY_CONFIRM_WIN),onShowAlert)
			//通知玩家家族造反开启
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_GUILD_PUTSCH_START),onFamilyWarOpen)
			//审核列表	
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SHOW_APPLY_INFO),onShowShengheFamily);
			
			//帮派解散
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_CLEAR_GUILD),onGuildHandle);
			
			//日志信息返回数据
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_UPDATE_GUILD_HISTORY),onFamilyMessage);
			
			model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_REFRESH_GUILD_APPLY_INFO),onUpdataShHandle);
			
			
		}
		private function createTableCell():void
		{	
			var text:TextField=new TextField;
			text.width = 65;
			text.height = _tab.itemHeight// - 4;
			text.htmlText=getOperationStr("")
//			btn_Cell.visible = true;
			//加入到table中
			_tableCellFactory = new TableCellFactory(_tab, windowBG,
				text,4);
			_tableCellFactory.TablePageChangeData = tablePageChangeData; 
		}
		private function tablePageChangeData():void
		{
			if(info_tab.selected == 1 )
			{
				var pageCount:int = _tab.pageLinesConut;
				for(var i:int=0; i<pageCount; ++i)
				{
					var pn:String = _tab.getItemFrom(
						new NxTabelPos(i+_tab.currentPage*pageCount));
					
					var cell:TextField;
					if(pn != "" && pn != null)				
					{
						cell = _tableCellFactory.ArrTabelCell[i]
						if(cell == null)
							continue;
						cell.htmlText=getOperationStr(pn);
						cell.addEventListener(TextEvent.LINK, linkEventHandle);					
					}
				}
			}
		}
		private function onUpdataShHandle(e:CustomMsgEvent):void
		{
			if(info_tab.selected == 1)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_APPLY_INFO);
			}
		}
		
		private function onGuildHandle(e:CustomMsgEvent):void
		{
			FamilyInfoUI.getInstance().showOrHide();
		}
		
		private function onInit():void
		{
			_description	.text		=	"";
			_familyName		.htmlStr		=	"";
			_familyShaikh	.htmlStr		=	"";
			_familyLevel	.htmlStr		=	"";
			_familyExp		.htmlStr		=	"";
			_familyMember	.htmlStr		=	"";
//			_familyDataExp	.htmlStr		=	"";
//			_familyDataWelfare.htmlStr		=	"";
			_seltFamilyRole					=	["",-1];//"";
			_familyPlace					=	-1;
			
			_tab			.dataProvider=null;
			
			_pageUpBtn		.enabled		=	false;
			_pageNextBtn	.enabled		=	false;

			
			_familyRankBtn		.enabled		=	true;
//			_familyRank2Btn		.enabled		=	true;

		}
		
		/**
		 *帮派成员日志处理 
		 * @param e
		 * 
		 */
		public function onFamilyMessage(e:CustomMsgEvent):void
		{
//			if(info_tab.selected != 2)
//				return;
			if(info_tab.dataProvider.length < info_tab.selected+1 )
				info_tab.selected = info_tab.dataProvider.length - 1;
			if(info_tab.selected == 1)
			{
				info_tab.selected == 2;
			}
			if(info_tab.dataProvider[info_tab.selected]["data"] != "UIString_1000564")
				return;
			checkBox.visible = false;
			lab_showAllRole.visible = false;
			_tab.dataProvider = null;
			if(_tableCellFactory)
				_tableCellFactory.destroy();
			_tab.titleLabels = [
				StaticIni.getSwfLangStr("UIString_1000565"),
				StaticIni.getSwfLangStr("UIString_1000566")];
			var columWidth:int = _tab.width / _tab.titleLabels.length;
			_tab.columWidthArr = [_tab.width*0.8,_tab.width*0.2];
			var messageArr	:Array 			= 	e.pList as Array;
			
			var serverTime:int = messageArr.shift();
			//数据列数(类型，玩家名称，数值，数值，时间)
			var	colT		:uint			=	4;
			//数据记录条数
			var familyNumT	:int			=	messageArr.length/colT
			var dataPrivater:Array=[];
			_tab.dataProvider = null;
			_tab.itemAlign = TextFormatAlign.LEFT;
//			_tab.columWidthArr = [];
			for(var i:int = 0; i < familyNumT; i ++)
			{
				var itemL		:Array			=	new Array();
				//类型
				var type		:String			=	messageArr[i*colT];
				//玩家名字
				var playName	:String		=	messageArr[i*colT+2] ;
				//时间
				var time		:String 		= changeTime(serverTime - messageArr[i*colT+1]);
//				1：Guild_Exp XXX获得XXX声望，为帮派贡献了XXX经验
//				2：Guild_Join XXX加入了帮派
//				3：Guild_Leave XXX离开了帮派
//				4：XXX被提升为副帮主
//				5：Guild_Pos == 1   XXX被提升为帮主
				var messageStr:String = "";
				switch (type)
				{
					case "Guild_Exp":
						messageStr = StaticIni.getSwfLangStrVar("UIString_1000559",[playName,messageArr[i*colT+3],messageArr[i*colT+3]]);
						itemL			.push(messageStr);
						itemL			.push(time);
						_tab			.addLineByIndex(itemL, -1,	"");
						break;
					case "Guild_Join":
						messageStr = StaticIni.getSwfLangStrVar("UIString_1000560",[playName,messageArr[i*colT+3]]);
						itemL			.push(messageStr);
						itemL			.push(time);
						_tab			.addLineByIndex(itemL, -1,	"");
						break;
					case "Guild_Leave":
						messageStr = StaticIni.getSwfLangStrVar("UIString_1000561",[playName,messageArr[i*colT+3]]);
						itemL			.push(messageStr);
						itemL			.push(time);
						_tab			.addLineByIndex(itemL, -1,	"");
						break;
					case "Guild_Pos":
						if(messageArr[i*colT+3] == 1)
						{
							messageStr = StaticIni.getSwfLangStrVar("UIString_1000563",[playName,messageArr[i*colT+3]]);	
						}else if(messageArr[i*colT+3] == 2 )
						{
							messageStr = StaticIni.getSwfLangStrVar("UIString_1000562",[playName,messageArr[i*colT+3]]);	
						}else if( messageArr[i*colT+3] == 3)
						{
							messageStr = StaticIni.getSwfLangStrVar("UIString_1000569",[playName,messageArr[i*colT+3]]);
						}
						itemL			.push(messageStr);
						itemL			.push(time);
						_tab			.addLineByIndex(itemL, -1,	"");
						break;
					default :
						if(messageStr == "")
						{
							continue;
						}else
						{
							itemL			.push(messageStr);
							itemL			.push(time);
							_tab			.addLineByIndex(itemL, -1,	"");
						}
					
				}
			}
//			createTableCell();	
			_pageTurner.onPageDis();
//			_tableCellFactory.tableTurn();
		}
		
		
		/**
		 *根据秒数获得距离现在的时间 
		 * @param t
		 * @return 
		 * 
		 */
		private function  changeTime(t:int):String
		{
			t			=	t<0	?	0	:	t;
			var d:int	=	int(	t/(60*60*24)				);
			var h:int	=	int(	t%(60*60*24)/(60*60)		);
			var m:int	=	int(	t%(60*60)/(60)				);
			var str:String = "";
			if(d>0)
			{
				str =  StaticIni.getSwfLangStrVar("UIStr_1001887",[d]);//xx天前
			}
			else if(h>0)
			{
				str = StaticIni.getSwfLangStrVar("UIStr_1001886",[h]);//xx小时前
			}
			else
			{
				m = m>0 ? m : 1;
				str = StaticIni.getSwfLangStrVar("UIString_1000089",[m]);//xx分钟前
			}
			return str;
		}
		
		/**
		 *审核列表返回数据 
		 * @param e
		 * 
		 */
		public function onShowShengheFamily(e:CustomMsgEvent):void
		{
//			onInit();
			if(info_tab.dataProvider.length < info_tab.selected+1 )
				info_tab.selected = info_tab.dataProvider.length - 1;
			if(info_tab.dataProvider[info_tab.selected]["data"] != "GuildUIStr_16")
				return;
//			if(info_tab.selected!=1)
//				return ;
			checkBox.visible = false;
			lab_showAllRole.visible = false;
			_tab.dataProvider = null;
			if(_tableCellFactory)
			_tableCellFactory.destroy();
			_tab.itemAlign = TextFormatAlign.CENTER;
			_tab.titleLabels = [StaticIni.getSwfLangStr("UIStr_1000203"),
				StaticIni.getSwfLangStr("UIStr_1000043"),
				StaticIni.getSwfLangStr("UIStr_1000046"),
//				StaticIni.getSwfLangStr("UIStr_1000080"),
				StaticIni.getSwfLangStr("UIStr_1000496"),
				StaticIni.getSwfLangStr("UIString_1000108")];//UIString_1000108 操作
			var columWidth:int = _tab.width / _tab.titleLabels.length;
			_tab.columWidthArr = [columWidth,columWidth,columWidth,columWidth,columWidth];
			var m_updateArr	:Array 			= 	e.pList as Array;
			//数据列数(名称，等级，职业，城堡，申请时间)
			var	colT		:uint			=	5;
			//数据记录条数
			var familyNumT	:int			=	m_updateArr.shift();
			var dataPrivater:Array=[];
			_tab.dataProvider = null;
			_tab.columWidthArr = [];
			for(var i:int = 0; i < familyNumT; i ++)
			{
				var itemL		:Array			=	new Array();
				var ShaikhT		:String			=	m_updateArr[i*colT];
				var applyTimeT	:String			=	m_updateArr[i*colT+4].split(" ")[0];
				
				itemL			.push(ShaikhT);
				itemL			.push(m_updateArr[i*colT+1]);
				
				var prof:int = m_updateArr[i*colT+2];
//				var profStr:String = "";
//				if(prof<10)
//				{
//					profStr = "00"+prof;
//				}else if(prof<100)
//				{
//					profStr = "0" +prof;
//				}else
//				{
//					profStr = prof.toString();
//				}
//				itemL.push(StaticIni.getSwfLangStr("ProftypeString_"+ profStr));
				
				itemL.push(GameDefine.PART_GANG(prof));//这个就是门派吧
//				itemL			.push(StaticIni.getSwfLangStr(m_updateArr[i*colT+3].split(",").join("_npcscene_")));
				itemL			.push(applyTimeT);
				itemL			.push((" "));
				_tab			.addLineByIndex(itemL, -1,	ShaikhT);
//				dataPrivater.push( itemL);
			}
			createTableCell();	
			_pageTurner.onPageDis();
			_tableCellFactory.tableTurn();

//			_tab.dataProvider = dataPrivater;
//			model			.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_REFRESH_GUILD_INFO),onShowFamily);
		}
		private function linkEventHandle(e:TextEvent):void
		{
			var arr:Array=e.text.split(SPLITER);
			if(AGREE_STR.indexOf(String(arr[0]))>-1)
			{
				agreeIn(arr[1])
			}
			else if(DECLINE_STR.indexOf(String(arr[0]))>-1)
			{
				declineIn(arr[1])
			}
			
		}
		private function getOperationStr(name:String):String
		{
			return 				TipsMainLogic.instance.getUnderLineHtml(AGREE_STR,AGREE_STR+SPLITER+name)+"    "
				+TipsMainLogic.instance.getUnderLineHtml(DECLINE_STR,DECLINE_STR+SPLITER+name);
		}
		private function onManageClick(e:MouseEvent):void
		{
			if((e.currentTarget as NxButton).label == StaticIni.getSwfLangStr("UIStr_1000520"))
			{
				onExitClick();
			}
			else
			{
				var tempArr:Array = [];
				var lenth:int = menuList.length;
				for(var i:int = 0;i<lenth;i++)
				{
					tempArr.push(StaticIni.getSwfLangStr(menuList[i]));
				}
				MenuList.ShowMenu(tempArr,onMenuClick);
			}
		}
		
		private function onMenuClick(type:uint,clickData:*):void
		{
			var memberStr:String = menuList[type];
			switch(memberStr)
			{
				case "UIStr_1000523":
					onPlacardClick();
					break;
				case "UIStr_1000522":
					onDoApplyClick();
					break;
				case "UIStr_1000519":
					onInviteClick();
					break;
				case "Familyinfo_Leadoperate":
					onDismissClick();
					break;
				case "UIStr_1000520"://退出帮派
					onExitClick();
					break;
				default:
//					trace("no match!");
			}
		}
		
		private function onTreasureClick(e:MouseEvent):void
		{
//			UIManage.getInstance().requestOpenUI(FamilyTreasureUI.getInstance());
		}
		
		/**
		 * 家族领地战主界面
		 */		
		/*private function onBattleClick(e:MouseEvent):void
		{
			if(WorldMapNewUI.getInstance().stage == null)
			{
				UIManage.getInstance().requestOpenUI(WorldMapNewUI.getInstance());
			}
		}*/
		
		/**
		 *可用功能控制
		 * 
		 */		
		private function onAbleFunc():void
		{
			menuList.length	=	0;
			if(1 == _familyPlace)//族长 1 服务器定义
			{
				_familyExitBtn.visible = false;
				_familyPlacardBtn.visible = true;
				btn_switchHead.visible = true;
				_FamilyDismissBtn.visible = true;
				_familyInviteBtn.visible		=	true;
//				manageBtn.label = StaticIni.getSwfLangStr("UIStr_1000497");//家族管理
				menuList.push("UIStr_1000523");//家族公告
				menuList.push("UIStr_1000522");//处理申请
				menuList.push("UIStr_1000519");//邀请成员
				menuList.push("Familyinfo_Leadoperate");//族长操作
				info_tab.dataProvider = [
					{label:StaticIni.getSwfLangStr("GuildUIStr_15"),data:"GuildUIStr_15"},
					{label:StaticIni.getSwfLangStr("GuildUIStr_16"),data:"GuildUIStr_16"},
					{label:StaticIni.getSwfLangStr("UIString_1000564"),data:"UIString_1000564"},
					{label:StaticIni.getSwfLangStr("UIString_1000736"),data:"UIString_1000736"}];
				/*_familyInviteBtn.enabled		=	true;
				_FamilyDismissBtn.enabled		=	true;
				_familyDoApplyBtn.enabled		=	true;
				_familyPlacardBtn.enabled		=	true;
				_familyRankBtn	.enabled		=	true;*/
				//_gainFamilyChaeBtn.enabled		=	true;
				
			}
			else if(2 == _familyPlace)//长老 2
			{
				_familyExitBtn.visible = true;
				_familyPlacardBtn.visible = false;
				btn_switchHead.visible = false;
				_FamilyDismissBtn.visible = false;
				_familyInviteBtn.visible		=	false;
//				manageBtn.label = StaticIni.getSwfLangStr("UIStr_1000497");
				menuList.push("UIStr_1000522");
				menuList.push("UIStr_1000519");
				menuList.push("UIStr_1000520");//退出家族
				info_tab.dataProvider = [
					{label:StaticIni.getSwfLangStr("GuildUIStr_15"),data:"GuildUIStr_15"},
					{label:StaticIni.getSwfLangStr("GuildUIStr_16"),data:"GuildUIStr_16"},
					{label:StaticIni.getSwfLangStr("UIString_1000564"),data:"UIString_1000564"},
					{label:StaticIni.getSwfLangStr("UIString_1000736"),data:"UIString_1000736"}];
				/*_familyInviteBtn.enabled		=	true;
				_familyExitBtn	.enabled		=	true;
				_familyDoApplyBtn.enabled		=	true;
				_familyRankBtn	.enabled		=	true;*/
				//_gainFamilyChaeBtn.enabled		=	true;
			}
			else if(3 == _familyPlace)//会众 3
			{
				_familyExitBtn.visible = true;
				_familyPlacardBtn.visible = false;
				btn_switchHead.visible = false;
				_FamilyDismissBtn.visible = false;
				_familyInviteBtn.visible		=	false;
//				manageBtn.label = StaticIni.getSwfLangStr("UIStr_1000520");
				info_tab.dataProvider = [
					{label:StaticIni.getSwfLangStr("GuildUIStr_15"),data:"GuildUIStr_15"},
					{label:StaticIni.getSwfLangStr("UIString_1000564"),data:"UIString_1000564"},
					{label:StaticIni.getSwfLangStr("UIString_1000736"),data:"UIString_1000736"}];
				/*_familyExitBtn	.enabled		=	true;
				_familyRankBtn	.enabled		=	true;*/
				//_gainFamilyChaeBtn.enabled		=	true;
			}
		}
		
		public function onShowFamilyUI(e:CustomMsgEvent):void
		{
			if(this.parent == null)
			{
			this.showOrHide(StageInfo.uiSpace);
			}
			onShowFamily(e);
		}
		
		//消息格式：unsigned msgid, widestr 公告,widestr 家族名称, widestr 族长, int 等级, int 家族声望，int 成员数量, 
		//int position, wstring playerName, int playerLevel, int playerProf, wstring castleName, int online ,int nowContr,int totalCont,……
//		public function onShowFamily():void
		public function onShowFamily(e:CustomMsgEvent):void
		{
			var m_updateArr	:Array 			= 	e.pList as Array;
			if(m_updateArr.length<7)return;
			
//			onInit();
			
			_description	.color = 0xffffff;
			_description	.text			=	ChatFilterLogic.getInstance().filter(m_updateArr.shift());
			_familyName		.htmlStr		=	m_updateArr.shift();
			_familyShaikh	.htmlStr		=	m_updateArr.shift();
			_familyLevel	.htmlStr		=	m_updateArr.shift();
			
			_familyMember	.htmlStr		=	m_updateArr.shift();//成员数量
			_familyMember	.htmlStr += "/"+StaticIni.getIniVar("familyUP_"+_familyLevel.text,"count");
			
			var senwangT	:int			=	m_updateArr.shift();//家族声望
			_familyCurExp					=	senwangT;
			_familyExp		.htmlStr		=	String(senwangT) +"/"+StaticIni.getIniVar("familyUP_"+_familyLevel.text,"exp");

			lab_weakCount	.htmlStr = StaticIni.getSwfLangStrVar("UIString_1000096",[m_updateArr.shift()]); 
			//数据列数(职务，名称，等级，职业，城堡，状态-0离线 1在线)
			var	colT		:uint			=	10;
			//数据记录条数
			var familyNumT	:int			=	m_updateArr.length/colT;
			var	myNameT		:String			=	model.scene.Role.GetProperties("Name");
			_switchDataArr = [];
//			if(info_tab.selected != 0 )
//			{
//				return;
//			}
//			_tab.dataProvider = null;
			if(_tableCellFactory)
			_tableCellFactory.destroy();
			_tanheBtn.visible = false;
			showdataList = [];
			for(var i:int = 0; i < familyNumT; i ++)
			{
				var itemL		:Array			=	new Array();
				var nameT		:String			=	m_updateArr[i*colT+1];
				
				var paramT		:Array			=	[nameT,m_updateArr[i*colT],m_updateArr[i*colT+8]];
				
				itemL.push(StaticIni.getSwfLangStr("FamilyPosition_"+(m_updateArr[i*colT])));
				itemL.push(m_updateArr[i*colT+1]);
				itemL.push(m_updateArr[i*colT+2]);
				var prof:int = m_updateArr[i*colT+3];
				var profStr:String = "";
				if(prof<10)
				{
					profStr = "00"+prof;
				}else if(prof<100)
				{
					profStr = "0" +prof;
				}else
				{
					profStr = prof.toString();
				}
					
					
				itemL.push(StaticIni.getSwfLangStr("NationString_"+ profStr));
				if(m_updateArr[i*colT+9]<=0)
				{//竞技排名
					
					itemL.push(StaticIni.getSwfLangStr("UIString_1000644"));//"未上榜"
				}else
				{
					itemL.push(m_updateArr[i*colT+9]);
				}
				itemL.push(m_updateArr[i*colT+7]);//今天贡献
				itemL.push(m_updateArr[i*colT+8]);//总贡献
				if(m_updateArr[i*colT]== 2)
				{//把是副帮主的加入数组
					_switchDataArr.push([{label:itemL[0]},{label:itemL[1],data:itemL[1]},{label:itemL[2]},{label:itemL[3]}]);
				}

				if(m_updateArr[i*colT+5] != 0)
				{//判断是不是在线
					itemL.push(StaticIni.getSwfLangStr("UIStr_100055"+(m_updateArr[i*colT+5]+2)));
				}
				else
				{
					checkTime(m_updateArr[i*colT+6]);
				}
			
				var t:int = m_updateArr[i*colT+6];
				t			=	t<0	?	0	:	t;
				var d:int	=	int(	t/(60*60*24)				);
				
				if(m_updateArr[i*colT]== 1 && m_updateArr[i*colT+5] == 0)
				{//弹核逻辑 是帮主且帮主不在线
					if( 6 <= d && d < 7 && nameT != model.scene.Role.getPlayerName())
					{
						_tanheBtn.visible = true;
						_tanheBtn.filters = [FilterUtil.GrayColorFilter];
						_timeCount = 60*60*24 - t%(60*60*24);
						if(_timer == null)
						{
							_timer = new Timer(1000);	
						}
						_timer.addEventListener(TimerEvent.TIMER,ontimehandle);
						_timer.start();
					}
					else if( d >=7  && nameT != model.scene.Role.getPlayerName())
					{
						_tanheBtn.visible = true;
						_tanheBtn.filters = [];
						
						_tanheTipsStr = StaticIni.getSwfLangStr( "UIString_1000515");
						
					}
					else
					{
						_tanheBtn.visible = false;
					}
				}
				
				if(m_updateArr[i*colT+5] == 0)
				{
					for(var m:int = 0;m<itemL.length;m++)
					{
						itemL[m] = StaticIni.getSwfLangStrVar("UIString_1000103",[itemL[m]]);
					}
				}else
					if(m_updateArr[i*colT] == 1||m_updateArr[i*colT] ==2)
					{
						for(var n:int = 0;n<itemL.length;n++)
						{
							itemL[n] = StaticIni.getSwfLangStrVar("UIStr_1001745",[itemL[n]]);
						}
					}
				var obj:Object = {};
				obj["itemL"] = itemL;
				obj["index"] = -1;
				obj["paramT"] = paramT;
				if(checkBox.currentFrame == 1 && m_updateArr[i*colT+5] != 0 )
				{
					
//					_tab			.addLineByIndex(itemL,-1,paramT);
					showdataList.push(obj);
				}
				if(checkBox.currentFrame == 2)
				{
					showdataList.push(obj);
//					_tab			.addLineByIndex(itemL,-1,paramT);
				}
				
				
				if(myNameT == nameT)
				{
					_familyPlace				=	m_updateArr[i*colT];
				}
				function checkTime(t:int):void
				{
					t			=	t<0	?	0	:	t;
					var d:int	=	int(	t/(60*60*24)				);
					var h:int	=	int(	t%(60*60*24)/(60*60)		);
					var m:int	=	int(	t%(60*60)/(60)				);
					if(d>0)
					{
						itemL.push(StaticIni.getSwfLangStrVar("UIStr_1001887",[d]));//xx天前
					}
					else if(h>0)
					{
						itemL.push(StaticIni.getSwfLangStrVar("UIStr_1001886",[h]));//xx小时前
					}
					else
					{
						m = m>0 ? m : 1;
						itemL.push(StaticIni.getSwfLangStrVar("UIString_1000089",[m]));//xx分钟前
					}
				}
			}
			
			onAbleFunc();
			if(info_tab.dataProvider.length < info_tab.selected+1 )
				info_tab.selected = info_tab.dataProvider.length - 1;
			if(info_tab.dataProvider[info_tab.selected]["data"] != "GuildUIStr_15")
				return;
			
			checkBox.visible = true;
			lab_showAllRole.visible = true;
			_tab.itemAlign = TextFormatAlign.CENTER;
			_tab.titleLabels = [StaticIni.getSwfLangStr("GuildUIStr_12"),
				StaticIni.getSwfLangStr("UIStr_1000203"),
				StaticIni.getSwfLangStr("UIStr_1000043"),
				StaticIni.getSwfLangStr("GuildUIStr_13"),
				StaticIni.getSwfLangStr("UIStr_1001703"),
				StaticIni.getSwfLangStr("UIStr_1001867"),
				StaticIni.getSwfLangStr("GuildUIStr_14"),
				StaticIni.getSwfLangStr("UIStr_1000876")];
			var columWidth:int = _tab.width / _tab.titleLabels.length;
			_tab.columWidthArr = [columWidth,columWidth,columWidth,columWidth,columWidth,columWidth,columWidth,columWidth];
			_tab.dataProvider = [];
			for(var j:int = 0;j < showdataList.length;j ++)
			{
				_tab			.addLineByIndex(showdataList[j].itemL,showdataList[j].index,showdataList[j].paramT);
			}
			
			var familyArr:Array	=	_tab.dataProvider;
			familyArr.sort(sortFamilyArr,Array.DESCENDING);
			_tab.dataProvider	=	familyArr;
			
			//初始化 翻页显示信息
			_pageTurner.onPageDis();
//			model			.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_REFRESH_GUILD_INFO),onShowFamily);
		}
		
		private function ontimehandle(e:TimerEvent):void
		{
			if(_timeCount<1)
			{
				TipsMainLogic.instance.hide();
				if(_timer)
				{
					_timer.stop();
					_timer.removeEventListener(TimerEvent.TIMER,ontimehandle);
					_timer = null;
				}
				_tanheBtn.filters = [];
				tanheflag = false;
			}else
			{
				_timeCount -- ;
				var h:int	=	int(	_timeCount/(60*60)		);
				var m:int	=	int(	_timeCount%(60*60)/(60)				);
				var s:int 	=	int(	_timeCount%(60)			);
				_tanheTipsStr = StaticIni.getSwfLangStrVar("UIString_1000514",[h<10?"0"+h+":":h+":",m<10?"0"+m+":":m+":",s<10?"0"+s:s]);
				if(tanheflag)
				{
					TipsMainLogic.instance.showString(_tanheTipsStr);
				}
			}
		}
		
		
		/**
		 * 获取家族金库 propName ,value
		 */		
		private function onShowGold(e:CustomMsgEvent):void
		{
//			goldNum.htmlStr			=		String(e.pList[1]);
		}
		
		//按家族地位排序
		private function sortFamilyArr(before:*,after:*):int
		{
			if( int(before[0].data[1]) > (after[0].data[1]) )
			{
				return -1;
			}
			else if(int(before[0].data[1]) < (after[0].data[1]))
			{
				return 1;
			}
			
			if( int(before[0].data[2]) > (after[0].data[2]) )
			{
				return 1;
			}
			else if(int(before[0].data[2]) < (after[0].data[2]))
			{
				return -1;
			}
			return 0;
		}
		

		/**
		 * 翻页前清空上页选中的家族
		 */
		private function beforePageTurn():void
		{
			_seltFamilyRole					=	["",-1];
		}
		
		/**
		 *邀请成员
		 * @param e
		 * 
		 */		
		private function onInviteClick(e:MouseEvent=null):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_RECRUIT_INFO);
//			FamilyInviteUI.getInstance().showOrHide();
		}
		
		private function onFamilyInvite(type:int, str:String, clickData:*):void
		{
			if(str && 0 < str.length) 
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST,
													GameDefine.REQUESTTYPE_GUILD,new WString(str));
			}			
			UIManage.getInstance().cancelCustUIMask();
		}
		
		/**
		 *退出家族 
		 * @param e
		 * 
		 */		
		private function onExitClick(e:MouseEvent=null):void
		{
			UIManage.getInstance().setCustUIMask(this.parent);
			
			var	titleT		:String			=	StaticIni.getSwfLangStr("UIStr_1000500");
			var	iniDescT	:String			=	StaticIni.getSwfLangStr("UIStr_1000543");
			AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
				if(type == AlertUI.YES){
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_LEAVE);
						//,new WString(_familyName.htmlStr));
				}
				UIManage.getInstance().cancelCustUIMask();
			});
		}
		
		/**
		 * 族长操作
		 * @param e
		 * 
		 */		
		private function onDismissClick(e:MouseEvent=null):void
		{
			UIManage.getInstance().setCustUIMask(this.parent);
			
			var	titleT		:String			=	StaticIni.getSwfLangStr("UIStr_1000521");
			var	iniDescT	:String			=	StaticIni.getSwfLangStr("UIStr_1000544");
			AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
				if(type == AlertUI.YES)
				{
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_DISBAND);
				}
				UIManage.getInstance().cancelCustUIMask();
			});
//			PatrOperatingUI.getInstance().showUI(this);
		}
		
		/**
		 *处理申请 
		 * @param e
		 * 
		 */		
		private function onDoApplyClick(e:MouseEvent=null):void
		{
			
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_APPLY_INFO);
				//,new WString(_familyName.htmlStr));
		}
		
		
		/**
		 *家族公告 
		 * @param e
		 * 
		 */		
		private function onPlacardClick(e:MouseEvent=null):void
		{
			UIManage.getInstance().setCustUIMask(this.parent);
			
			FamilyPlacardUI.getInstance().onShowFamily(_description.htmlStr);
		}
		
		/**
		 *家族排行 
		 * @param e
		 * 
		 */		
		private function onRankClick(e:MouseEvent):void
		{
			//响应界面FamilyBrowseUI
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_ALL_GUILD_INFO);
			//获得所有家族信息列表
//			RankUI.getInstance().tabSelect(3);
//			UIManage.getInstance().requestOpenUI(RankUI.getInstance());
			FamilyLogic.getInstance().ui.showOrHide();
		}
		
		/**
		 * 家族对抗
		 * @param e
		 * 
		 */		
		private function onGainChaeClick(e:MouseEvent):void
		{
//			UIManage.getInstance().requestOpenUI(FamilyWarUI.getInstance());
			//FamilyWarUI.getInstance().show();
			//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_ALL_GUILD_INFO,1);
		}
		
		/**
		 *家族排行2点击 
		 * 家族捐献
		 * @param e
		 * 
		 */		
		private function onRank2Click(e:MouseEvent):void
		{
//			DonateUI.getInstance().show(StageInfo.uiSpace);
		}
		
		/**
		 *表行记录点击 
		 * @param e
		 * 
		 */		
		private function onTbClick(e:NxTableEvent):void
		{
			if(info_tab.selected == 0 )
			{
				infoTabClickHandle(e);
			}else if(info_tab.selected == 1)
			{
				shengHeTabClickHandle(e);
			}else if(info_tab.selected == 2)
			{
				
			}
			
		}
		
		/**
		 *审核表点击处理函数 
		 * @param e
		 * 
		 */
		private function shengHeTabClickHandle(e:NxTableEvent):void
		{
			var clickX:int			= e.pos.row;
			var clickY:int			= e.pos.colum;
			var nowPage:int		 	= e.currentTarget.currentPage;
			var tableMaxLine:int 	= e.currentTarget.pageLinesConut;
			var paramT		:String
			if(e.currentTarget.getLineByIndex(clickX + (tableMaxLine * nowPage)) == null)
			{
				return;
			}else
			{
				paramT	=	e.currentTarget.getLineByIndex(clickX + (tableMaxLine * nowPage))[0].data;
			}
			
			if("" == paramT)
			{
				MenuList.hide();
				return;
			}
			
			var menuItemList	:Array 	= 	new Array();
			menuItemList.push(StaticIni.getSwfLangStr("Common_Look"));//查看
			menuItemList.push(StaticIni.getSwfLangStr("UIStr_1000209"));//批准
			menuItemList.push(StaticIni.getSwfLangStr("UIStr_1000210"));//拒绝
			
			MenuList.ShowMenu(menuItemList,function onMenuFunc(i:uint,data:Object=null):void{
				if(0 == i)
				{
					ActorPropertyLogic.getInstance().lookOver(paramT);
				}
				else if(1 == i)
				{
					agreeIn(paramT);
				}
				else if(2 == i)
				{
					declineIn(paramT);
				}
			});
		}
		/**
		 *批准加入 
		 * @param name
		 * 
		 */		
		public function agreeIn(name:String):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_ACCEPT_JOIN_GUILD,new WString(name));
		}
		/**
		 *拒绝加入 
		 * @param name
		 * 
		 */		
		public function declineIn(name:String):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_REJECT_JOIN_GUILD,new WString(name));
		}
		/**
		 *
		 *家族成员表点击处理函数 
		 * @param e
		 * 
		 */
		private function infoTabClickHandle(e:NxTableEvent):void
		{
			if( -1 == _familyPlace)
			{
				return;
			}
			
			//重构paramT，以便其他部分的数据调用方式
			var target:NxTable=NxTable(e.target)
			var index:Number=e.pos.row+target.currentPage*target.pageLinesConut;
			
			if(target.dataProvider[index]){
				var paramT:Array=target.dataProvider[index][0].data;
				//				var paramT:String=target.dataProvider[index][0].data;
				var memberName:String = target.dataProvider[index][1].label;
			}else{
				return;
			}
			//重构paramT End		
			//			var	paramT		:Array			=  itemData as Array;
			_seltFamilyRole					=	paramT;
			
			if(1 > _seltFamilyRole[0].length)
			{
				MenuList.hide();
				return;
			}

			if(_roleVo.getPlayerName() == _seltFamilyRole[0] )
			{
				MenuList.hide();
				return;
			}

			
			var menuItemList	:Array 		= 	new Array();
			var seltRolePlace	:int		=	paramT[1];
			menuItemList.push(StaticIni.getSwfLangStr("Common_Look"));//查看
			menuItemList.push(StaticIni.getSwfLangStr("UIString_1000098"));//加为好友
			menuItemList.push(StaticIni.getSwfLangStr("Common_Whisper"));//私聊
			if(1 == _familyPlace && 1 != seltRolePlace)
			{
//				menuItemList.push(StaticIni.getSwfLangStr("Common_Look"));//查看
				menuItemList	.push(StaticIni.getSwfLangStr("UIStr_1000547"));
//				menuItemList	.push(StaticIni.getSwfLangStr("Common_ChangeFamilyHost"));
				if(2 == seltRolePlace)//对长老，降为成员
				{
					menuItemList	.push(StaticIni.getSwfLangStr("UIStr_1000545"));
					MenuList		.ShowMenu(menuItemList,onFuncClick1,memberName);
				}
				else if(3 == seltRolePlace)//对成员，升为长老
				{
					menuItemList	.push(StaticIni.getSwfLangStr("UIStr_1000546"));
					MenuList		.ShowMenu(menuItemList,onFuncClick2,memberName);
				}
			}
			else if(2 == _familyPlace && 3 == seltRolePlace)
			{
//				menuItemList.push(StaticIni.getSwfLangStr("Common_Look"));//查看
				menuItemList	.push(StaticIni.getSwfLangStr("UIStr_1000547"));
				MenuList		.ShowMenu(menuItemList,onFuncClick3);
			}else 
			{
				MenuList		.ShowMenu(menuItemList,onFuncClick4);
			}
		}
		
		/**
		 *选中任务信息后的弹出功能菜单点击 
		 * 族长选中长老
		 * @param i
		 * 
		 */		
		private function onFuncClick1(i:uint,data:Object=null):void
		{
			//如果没有选中一个任务条
			if(1 > _seltFamilyRole[1])
			{
				return;
			}
			var	titleT		:String			=	StaticIni.getSwfLangStr("MessageUI_Notice");
			var	iniDescT	:String			=	"";
			
			if(0 == i)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_LOOK_EQUIPS,new WString(_seltFamilyRole[0]));
			}else if(1 == i)//加为好友
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST,GameDefine.REQUESTTYPE_FRIEND,
					new WString(_seltFamilyRole[0]));
			}
			else if(2 == i)//私聊
			{
				WhisperLogic.getInstance().whisperSart(_seltFamilyRole[0]);
			}
			else if(3 == i)//开除
			{
				iniDescT = StaticIni.getSwfLangStrVar("UIStr_1001110",[_seltFamilyRole[0]]);
				
				UIManage.getInstance().setCustUIMask(this.parent);
				
				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
					if(type == AlertUI.YES)
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_DISMISS,
							new WString(_seltFamilyRole[0]));
					}
					UIManage.getInstance().cancelCustUIMask();
				});
			}
//			else if(1 == i)//移交族长
//			{
//				UIManage.getInstance().setCustUIMask(this.parent);
//				
//				iniDescT						=	StaticIni.getSwfLangStr("UIStr_1000564");
//				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
//					if(type == AlertUI.YES)
//					{
//						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_CHANGECOMMANDER,
//							new WString(_seltFamilyRole[0]));
//					}
//					UIManage.getInstance().cancelCustUIMask();
//				});
//			}
			else if(4 == i)//降为成员
			{
				iniDescT = StaticIni.getSwfLangStrVar("UIStr_1001841",[data]);
				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
					if(type == AlertUI.YES)
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_CHANGEMEMBERPOS,
							new WString(_seltFamilyRole[0]),3);
					}
					UIManage.getInstance().cancelCustUIMask();
				});
				
			}
		}
		
		/**
		 * 族长选中成员
		 * @param i
		 * @param data
		 * 
		 */		
		private function onFuncClick2(i:uint,data:Object=null):void
		{
			//如果没有选中一个任务条
			if(1 > _seltFamilyRole[1])
			{
				return;
			}
			var	titleT		:String			=	StaticIni.getSwfLangStr("MessageUI_Notice");
			var	iniDescT	:String			=	StaticIni.getSwfLangStr("UIStr_1000564");
			//共享
			
			if(0 == i)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_LOOK_EQUIPS,new WString(_seltFamilyRole[0]));
			}else if(1 == i)//加为好友
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST,GameDefine.REQUESTTYPE_FRIEND,
					new WString(_seltFamilyRole[0]));
			}
			else if(2 == i)//私聊
			{
				WhisperLogic.getInstance().whisperSart(_seltFamilyRole[0]);
			}
			else if(3 == i)//开除
			{
				iniDescT = StaticIni.getSwfLangStrVar("UIStr_1001110",[_seltFamilyRole[0]]);
				
				UIManage.getInstance().setCustUIMask(this.parent);
				
				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
					if(type == AlertUI.YES)
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_DISMISS,
							new WString(_seltFamilyRole[0]));
					}
					UIManage.getInstance().cancelCustUIMask();
				});
			}
//			else if(2 == i)//移交族长
//			{
//				UIManage.getInstance().setCustUIMask(this.parent);
//				
//				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
//					if(type == AlertUI.YES)
//					{
//						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_CHANGECOMMANDER,
//							new WString(_seltFamilyRole[0]));
//					}
//					UIManage.getInstance().cancelCustUIMask();
//				});
//			}
			else if(4 == i)//提升为长老
			{
				iniDescT = StaticIni.getSwfLangStrVar("UIStr_1001842",[data]);
				UIManage.getInstance().setCustUIMask(this.parent);
				
				AlertUI.showAlert(titleT,iniDescT,AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
					if(type == AlertUI.YES)
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_CHANGEMEMBERPOS,
							new WString(_seltFamilyRole[0]),2);
					}
					UIManage.getInstance().cancelCustUIMask();
				});
			}
		}
		
		
		/**
		 * 成员点击点击
		 * @param i
		 * @param data
		 * 
		 */		
		private function onFuncClick4(i:uint,data:Object=null):void
		{
			//如果没有选中一个任务条
			if(1 > _seltFamilyRole[1])
			{
				return;
			}
			if(0 == i)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_LOOK_EQUIPS,new WString(_seltFamilyRole[0]));
			}
			else if(1 == i)//加为好友
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST,GameDefine.REQUESTTYPE_FRIEND,
					new WString(_seltFamilyRole[0]));
			}
			else if(2 == i)//私聊
			{
				WhisperLogic.getInstance().whisperSart(_seltFamilyRole[0]);
			}
		}
		
		/**
		 * 长老选中成员
		 * @param i
		 * @param data
		 * 
		 */		
		private function onFuncClick3(i:uint,data:Object=null):void
		{
			//如果没有选中一个任务条
			if(1 > _seltFamilyRole[1])
			{
				return;
			}
			if(0 == i)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_LOOK_EQUIPS,new WString(_seltFamilyRole[0]));
			}else if(1 == i)//加为好友
			{
				
			}
			else if(2 == i)//私聊
			{
				WhisperLogic.getInstance().whisperSart(_seltFamilyRole[0]);
			}
			else if(3 == i)//开除
			{
				UIManage.getInstance().setCustUIMask(this.parent);
				
				AlertUI.showAlert(StaticIni.getSwfLangStr("MessageUI_Notice"),
					StaticIni.getSwfLangStrVar("UIStr_1001110",[_seltFamilyRole[0]]),
					AlertUI.YES|AlertUI.NO,function(type:int, str:String, clickData:*):void{
					if(type == AlertUI.YES)
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_DISMISS,
							new WString(_seltFamilyRole[0]));
					}
					UIManage.getInstance().cancelCustUIMask();
				});
			}
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_DISMISS,
//				new WString(_seltFamilyRole[0]));
		}
		/**
		 * 申请加入城堡的请求信息
		 * 只有城堡主才可以接收到 
		 * @param e
		 * 
		 */		
		private function onShowAlert(e:CustomMsgEvent):void
		{
			var title	:String = StaticIni.getSwfLangStr("MessageUI_Notice");
			var msg		:String = StaticIni.getSwfLangStr("MessageUI_Notice");
			AlertUI.showAlert(title,msg,AlertUI.YES|AlertUI.NO,result);
		}
		/**
		 * 通知玩家家族造反开启 
		 * @param e
		 * 
		 */		
		private function onFamilyWarOpen(e:CustomMsgEvent):void
		{

			var title:String	=	StaticIni.getSwfLangStr("MessageUI_Notice");
			var msg		:String = StaticIni.getSwfLangStr(e.pList[1]);
			AlertUI.showAlert(title,msg,AlertUI.YES|AlertUI.NO,sendChang,e.pList);
		}
		/**
		 * 确认后发送打开事件 
		 * @param clickName
		 * @param inputTxt
		 * @param clickData
		 * 
		 */		
		private function result(clickName:uint,inputTxt:String,clickData:Array):void
		{
			if(clickName==AlertUI.YES){
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERY_GUILD_BETRAY_INFO);
			}	
		}
		/**
		 *  
		 * @param clickName
		 * @param inputTxt
		 * @param clickData
		 * 
		 */		
		private function sendChang(clickName:uint,inputTxt:String,clickData:Array):void
		{
			if(clickName==AlertUI.YES){
				if(clickData[0] == 0){
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_PUTSCH_PUTSCHIST_TRANSFER );
					
				}else if(clickData[0] == 1){
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_PUTSCH_MASTER_TRANSFER );
					
				}
				
			}
		}
		
		/**
		 * 页签事件
		 * @param	e
		 */
		private function tabClickHandle(e:NxTabEvent):void 
		{
			var tabClickType:String	=	info_tab.dataProvider[e.seleted]["data"];
			
			_fuliMc.visible			= false;
			_fuliLevel.visible		= false;
			_fuliloading.visible	= false;
			_fulileft.visible		= false;
			_fuliGroup.visible		= false;
			_fuliBg.visible			= false;
			_fuliLine.visible		= false;
			_fuliMc2.visible		= false;
			_fuliloadLab.visible	= false;
			_tab.visible			= true;
			_pageUpBtn.visible		= true;
			_pageBg.visible			= true;
			_pageNextBtn.visible	= true;
			_pageNextBtn.visible	= true;
			_pageNum.visible		= true;
			checkBox.visible		= true;
			lab_showAllRole.visible	= true;
			switch (tabClickType) 
			{
				case "GuildUIStr_16":

					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_APPLY_INFO);
					break;
				case "GuildUIStr_15":
					var flagT	:String	=	model.scene.Role.GetProperties("GuildName");
					
//					model			.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_REFRESH_GUILD_INFO),onShowFamily);
					//查看公会详细信息
					SystemSender.getInstance().CustomMsg(
						CustomToServerFlag.CLIENT_CUSTOMMSG_GET_GUILD_INFO ,new WString(flagT));
					break;
				case "UIString_1000564":
					//查询帮派日志
					SystemSender.getInstance().CustomMsg(
						CustomToServerFlag.CLIENT_CUSTOMMSG_GET_GUILD_HISTORY);
					break;
				case "UIString_1000736":
					tabFuli();
					break;
				default:	
			}
			_pageTurner.onPageDis()
		}
		
		private function contrnalHandle(e:MouseEvent):void
		{
			var btn:NxButton = e.currentTarget as NxButton;
			switch(btn.label)
			{
				case StaticIni.getSwfLangStr("GuildUIStr_06"):
					onExitClick();
					break;
				case StaticIni.getSwfLangStr("GuildUIStr_10"):
					onDismissClick();
					break;
				case StaticIni.getSwfLangStr("GuildUIStr_09"):
					onPlacardClick();
					break;
				case StaticIni.getSwfLangStr("GuildUIStr_08"):
					FamilySwitchHeadLogic.getInstance().showUI(_switchDataArr);
					break;
				case StaticIni.getSwfLangStr( "UIString_1000461"):
					onInviteClick();
					break;
			}
			
		}
		
		private function oncheckBoxClickHandle(e:MouseEvent):void
		{
			var flagT	:String	=	model.scene.Role.GetProperties("GuildName");
		
			if(checkBox.currentFrame == 1)
			{
				checkBox.gotoAndStop(2);
			}else
			{
				checkBox.gotoAndStop(1);
			}
			if(0 < flagT.length)
			{
				//查看公会详细信息
				SystemSender.getInstance().CustomMsg(
					CustomToServerFlag.CLIENT_CUSTOMMSG_GET_GUILD_INFO ,new WString(flagT));
			}
		}
		/**
		 *点击帮派总坛 
		 * @param e
		 * 
		 */		
		private function onJoinBase(e:MouseEvent):void
		{
			if(WipeOutLogic.getInstance().WipeState)
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("97855"));//扫荡中不能打开
				return;
			}
			else if(CampBattleLogic.getInstance().isJoinCamp)
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("99198"));//阵营战开启中
				return;
			}
			//进入帮派总坛
			SystemSender.getInstance().CustomMsg(
				CustomToServerFlag.CLIENT_CUSTOMMSG_PLAYER_GUILD_SCENE);
			//临时用   打开上香界面
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SHOW_GUILD_DONATE);
		}
		private function onRemoveListener():void
		{
			checkBox				.removeEventListener(MouseEvent.CLICK,oncheckBoxClickHandle);
			btn_switchHead			.removeEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_FamilyDismissBtn		.removeEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyPlacardBtn		.removeEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyExitBtn			.removeEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyInviteBtn		.removeEventListener(  MouseEvent.CLICK,		contrnalHandle);
		 	baseBtn					.removeEventListener(MouseEvent.CLICK,		onJoinBase);
			
			windowBG				.removeEventListener(	NxWindowEvent.WINDOW_CLOSE,onClickClose);
//			manageBtn				.removeEventListener(MouseEvent.CLICK,		onManageClick);
//			_familyTreasureBtn		.removeEventListener(MouseEvent.CLICK,		onTreasureClick);
//			battleBtn				.removeEventListener(MouseEvent.CLICK,		onBattleClick);
			_tab					.removeEventListener(NxTableEvent.TABLE_CLICK,	onTbClick);		
			_pageTurner				.removeEventListener();	
			_familyRankBtn			.removeEventListener(  MouseEvent.CLICK,		onRankClick);
//			_familyRank2Btn			.removeEventListener(  MouseEvent.CLICK,		onRank2Click);
			info_tab				.removeEventListener(NxTabEvent.TAB_CLICK, 				tabClickHandle);
			_tanheBtn				.removeEventListener(MouseEvent.MOUSE_OVER			,ontanheOverHandle);
			_tanheBtn				.removeEventListener(MouseEvent.CLICK				,ontanheClickHandle);
			_tanheBtn				.removeEventListener(MouseEvent.MOUSE_OUT			,ontanheOutHandle);
			if(_timer)
			{
				_timer.stop();
				_timer.removeEventListener(TimerEvent.TIMER,ontimehandle);
				_timer = null;
			}
		
		}
		
		private function onClickClose(e:NxWindowEvent=null):void
		{
			this.showOrHide();	
		}
		
		private var tanheflag:Boolean = false;
		private function ontanheOverHandle (e:MouseEvent):void
		{
			tanheflag = true;
			TipsMainLogic.instance.showString(_tanheTipsStr);
		}
		
		
		private function ontanheOutHandle(e:MouseEvent):void
		{
			tanheflag = false;
			TipsMainLogic.instance.hide();
		}
	
		private function ontanheClickHandle(e:MouseEvent):void
		{
			AlertUI.showAlert(StaticIni.getSwfLangStr("MessageUI_Notice"),StaticIni.getSwfLangStr("UIString_1000516")
				,AlertUI.OK|AlertUI.CANCEL, alertclick)
			function alertclick(clickName:uint,inputTxt:String,clickData:Array):void
			{
				if(clickName==AlertUI.OK)
				{
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GUILD_CHAIRMMAN_INPEACH)
				}
			}
		}
		
		override protected	function	BeforeShow():void
		{	
			tanheflag = false;
			_widthArr = [];
			for(var i:int = 0;i<_tab.columWidthArr.length;i++)
			{
				_widthArr.push(_tab.columWidthArr[i]);
			}
			_pageTurner.addEventListener();
			checkBox				.addEventListener(MouseEvent.CLICK,oncheckBoxClickHandle);
			btn_switchHead			.addEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_FamilyDismissBtn		.addEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyPlacardBtn		.addEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyExitBtn			.addEventListener(  MouseEvent.CLICK,		contrnalHandle);
			_familyInviteBtn		.addEventListener(  MouseEvent.CLICK,		contrnalHandle);
			baseBtn					.addEventListener(MouseEvent.CLICK,		onJoinBase);
			windowBG				.addEventListener(	NxWindowEvent.WINDOW_CLOSE,onClickClose);
			_tab					.addEventListener(	NxTableEvent.TABLE_CLICK,	onTbClick);
			_familyRankBtn			.addEventListener(  MouseEvent.CLICK,		onRankClick);
			_tanheBtn				.addEventListener(MouseEvent.MOUSE_OVER			,ontanheOverHandle);
			_tanheBtn				.addEventListener(MouseEvent.CLICK				,ontanheClickHandle);
			_tanheBtn				.addEventListener(MouseEvent.MOUSE_OUT			,ontanheOutHandle);
			
//			_familyRank2Btn		.addEventListener(  MouseEvent.CLICK,		onRank2Click);
			
//			manageBtn			.addEventListener(MouseEvent.CLICK,		onManageClick);
			info_tab.addEventListener(NxTabEvent.TAB_CLICK, 				tabClickHandle);
			ActSee.PostClientStatus(8011,1,0);
			if(BottomIndexLogic.getInstance().checkBtnState("btn_7"))
			{
				info_tab.selected=1
			} else {
				info_tab.selected=0
			}
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_GUILD_PROP,"GuildGold");//获取家族金库
		}
		override protected function AfterHide():void
		{
			windowBG		.removeEventListener(  NxWindowEvent.WINDOW_CLOSE,onClickClose);
			tanheflag = false;
			TipsMainLogic.instance.hide();
			onRemoveListener();
		}
		
		/**
		 *切换至福利 
		 * 
		 */		
		private function tabFuli():void
		{
			//隐藏开启
			_fuliMc.visible			= true;
			_fuliLevel.visible		= true;
			_fuliloading.visible	= true;
			_fulileft.visible		= true;
			_fuliGroup.visible		= true;
			_fuliBg.visible			= true;
			_fuliLine.visible		= true;
			_fuliMc2.visible		= true;
			_fuliloadLab.visible	= true;
			_tab.visible			= false;
			_pageUpBtn.visible		= false;
			_pageBg.visible			= false;
			_pageNextBtn.visible	= false;
			_pageNextBtn.visible	= false;
			_pageNum.visible		= false;
			checkBox.visible		= false;
			lab_showAllRole.visible	= false;
			
			//设置各种信息
			const WELFWARE_COUNT:int = 8;
			var _level:int = int(_familyLevel.text);
			_fuliLevel.htmlText = StaticIni.getSwfLangStrVar("UIString_1000588", [_level]);
			
			var allExp:int = int(StaticIni.getIniVar("familyUP_"+ _level,"exp"));
			if(_level == 5 && (allExp - _familyCurExp) == 0){
				_fulileft.visible = false;
			} else {
				_fulileft.visible = true;
				_fulileft.htmlText = StaticIni.getSwfLangStrVar("UIString_1000589", [(allExp - _familyCurExp), (_level + 1)]);
			}
			
			_fuliloadLab.htmlText = "<font color = '#1eff00'>" + _familyCurExp + "</font>" + "/<font color = '#FFFFFF'>" + allExp + "</font>";
			var per:Number = _familyCurExp / allExp;
			_fuliloading.bar = int(per * 100);
			
			//初始化viewgroup
			for(var i:int = 0; i < WELFWARE_COUNT; i++){
				var mc:MovieClip = _fuliGroup.getItemByIndex(i) as MovieClip;
				var btn:NxButton = new NxButton;
				btn.x		= 0;
				btn.y		= 0;
				btn.width	= 73;
				btn.height	= 70;
				btn.label	= "";
				btn.visible	= false;
				mc["face"].addChild(btn);
				mc["btn"]				= btn;
				mc["Txt_1"].htmlText	= "";
				mc["di"].visible		= false;
			}
			
			var _welfareList:Array = StaticIni.getIniVar("FamilyWelfare_List", "List").split(",");
			var _showWelfArr:Array = new Array();
			for(i = 0; i < WELFWARE_COUNT; i++){
				mc 	= _fuliGroup.getItemByIndex(i) as MovieClip;
				var obj:Object = StaticIni.getIniObj(_welfareList[i]);
				if(obj == null) return;
				var isShow:Boolean	= (int(obj["openLevel"]) <= _level) ? true : false;
				showWelfare(mc, obj, isShow);
			}
		}
		
		private function showWelfare(mc:MovieClip, data:Object, isShow:Boolean):void
		{
			(mc["btn"] as NxButton).skin	= data["picName"];
			mc["di"].visible				= true;
			(mc["btn"] as NxButton).visible	= true;
			mc.mouseChildren = mc.mouseEnabled = mc.buttonMode = true;
			mc["data"]						= data;
			mc.addEventListener(MouseEvent.CLICK, fuliClickHandler);
			mc.addEventListener(MouseEvent.ROLL_OVER, fuliOverHandler);
			mc.addEventListener(MouseEvent.ROLL_OUT, fuliOutHandler);
			if(isShow){
				(mc["btn"] as NxButton).filters	= [];
				mc["isShow"]						= true;
				mc["Txt_1"].htmlText = StaticIni.getSwfLangStr(String(data["info"]));
			} else {
				(mc["btn"] as NxButton).filters	= [FilterUtil.GrayColorFilter];
				mc["isShow"]						= false;
				mc["Txt_1"].htmlText = StaticIni.getSwfLangStrVar("UIString_1000373", [data["openLevel"]]);
			}
		}
		
		private function fuliClickHandler(e:MouseEvent):void
		{
			var target:MovieClip = e.currentTarget as MovieClip;
			if(!target["data"]) return;
			if(!target["isShow"]) return;
			SceneTransfer.getInstance().tranferTo(target["data"]["transition"]);
		}
		
		private function fuliOverHandler(e:MouseEvent):void
		{
			var target:MovieClip = e.currentTarget as MovieClip;
			if(!target["data"]) return;
			TipsMainLogic.instance.showString(StaticIni.getSwfLangStr(String(target["data"]["tipinfo"])));
		}
		
		private function fuliOutHandler(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
	}
}
